/********************************************************************************
*                 Copyright (C) 2011 - Las Venturas Playground                  *
*                      http://sa-mp.nl | http://lvp-iv.com                      *
*                                                                               *
*    This program is free software: you can redistribute it and/or modify       *
*    it under the terms of the GNU General Public License as published by       *
*    the Free Software Foundation, either version 3 of the License, or          *
*    (at your option) any later version.                                        *
*                                                                               *
*    This program is distributed in the hope that it will be useful,            *
*    but WITHOUT ANY WARRANTY; without even the implied warranty of             *
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
*    GNU General Public License for more details.                               *
*                                                                               *
*    You should have received a copy of the GNU General Public License          *
*    along with this program.  If not, see <http://www.gnu.org/licenses/>.      *
*                                                                               *
*********************************************************************************
*                                                                               *
*  Las Venturas Playground - Minigames/deathmatchBase.nut                       *
*                                                                               *
*  Base class for deathmatch minigames.                                         *
*                                                                               *
*   Author:                                                                     *
*   Pugwipe <pugwipe@gmail.com>                                                 *
*                                                                               *
********************************************************************************/

class Minigames.Definition.DM extends Minigames.Definition.Base
{
}

class Minigames.Instance.DM extends Minigames.Instance.Base
{   
/*
    constructor (def)
    {
        Minigames.Instance.Base.constructor (def);
    }*/
    
    function onPlayerWasted (playerid, killerid, killervehicle)
    {
        Minigames.Instance.Base.onPlayerWasted (playerid, killerid, killervehicle);
        
        local minigameName = this.getDefinition ().getMinigameName ();
        local rank = this.getPlayersInMinigame ().len ();
        sendMessageToAll (getPlayerName (playerid) + " has been killed in the " + minigameName + ", rank " + rank.tostring());
        
        this.endForPlayer (playerid);
    }
    
    function onPlayerFinish (playerid)
    { 
        Minigames.Instance.Base.onPlayerFinish (playerid);
        
        local playersRemaining = this.getPlayersInMinigame ();
		
        if (playersRemaining.len () == 1)
        {
            local minigameName = this.getDefinition ().getMinigameName ();
			local winner = 0;
			
			foreach (i, playerid in this.getPlayersInMinigame())
			{
				winner = playerid;
			}
            
            sendMessageToAll (getPlayerName (winner) + " has won the " + minigameName + "!");
			
            this.endMinigame();
        }
    }   
}